
[dbo].[BAEOrderProductGetCrossSellSelected]
create procedure [dbo].[BAEOrderProductGetCrossSellSelected] @OrderProductID int as
SELECT op.OrderProductID, op.Title, op.[Description], op.IsSuperProduct, op.ProductCode, op.SellOnWeb
FROM OrderProduct AS op INNER JOIN Product p ON p.PRODUCT_CODE COLLATE database_default = op.ProductCode COLLATE database_default
WHERE op.IsSuperProduct = 0 AND op.OrderProductID <> @OrderProductID AND
op.OrderProductID IN (SELECT CrossSellOrderProductID FROM OrderProductCrossSellLookup
WHERE OrderProductID = @OrderProductID)
UNION
SELECT op1.OrderProductID, op1.Title, op1.[Description], op1.IsSuperProduct, op1.ProductCode, op1.SellOnWeb FROM OrderProduct AS op1
WHERE op1.IsSuperProduct = 1 AND op1.OrderProductID <> @OrderProductID AND
op1.OrderProductID IN (SELECT CrossSellOrderProductID FROM OrderProductCrossSellLookup
WHERE OrderProductID = @OrderProductID)
GO